/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SimNao.java
 *
 * Created on 28/01/2012, 11:09:42
 */
package Formularios;

import Metodos.CursoMet;
import Metodos.MinimizaTela;
import Metodos.ProfessorMet;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

/**
 *
 * @author André
 */
public class EscolherRelatorio extends javax.swing.JFrame {
static int i;
  MinimizaTela tela= new MinimizaTela();  
    public EscolherRelatorio() {
        try {
            tela.Minimiza(1);
        } catch (SQLException ex) {
            Logger.getLogger(EscolherRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        BufferedImage image=null;
        File imageFile=new File(".\\src\\Imagens\\logo3.png");
        try {
            image=ImageIO.read(imageFile);
            
        } catch (IOException ex) {
        }
        this.setIconImage(image);
        
        i=0;
//        BufferedImage image=new BufferedImage(10,10,BufferedImage.TYPE_INT_ARGB);
//        setIconImage(image);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        buton_adicionar = new javax.swing.JLabel();
        buton_deletar = new javax.swing.JLabel();
        jl_serie = new javax.swing.JLabel();
        buton_adicionar1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Relatório");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setLayout(null);

        jSeparator1.setBackground(new java.awt.Color(255, 153, 0));
        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(30, 10, 11, 300);

        buton_adicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/grade.jpg"))); // NOI18N
        buton_adicionar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_adicionar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_adicionarMouseClicked(evt);
            }
        });
        jPanel1.add(buton_adicionar);
        buton_adicionar.setBounds(320, 130, 330, 84);

        buton_deletar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/HORARIO21.jpg"))); // NOI18N
        buton_deletar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_deletar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_deletarMouseClicked(evt);
            }
        });
        jPanel1.add(buton_deletar);
        buton_deletar.setBounds(70, 140, 220, 70);

        jl_serie.setBackground(new java.awt.Color(0, 0, 0));
        jl_serie.setFont(new java.awt.Font("D3 Euronism italic", 1, 18)); // NOI18N
        jl_serie.setForeground(new java.awt.Color(255, 255, 255));
        jl_serie.setText("Qual Relatorio deseja gerar ?");
        jPanel1.add(jl_serie);
        jl_serie.setBounds(50, 50, 620, 30);

        buton_adicionar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/voltar.jpg"))); // NOI18N
        buton_adicionar1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_adicionar1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_adicionar1MouseClicked(evt);
            }
        });
        jPanel1.add(buton_adicionar1);
        buton_adicionar1.setBounds(260, 260, 180, 50);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/ACENTO.jpg"))); // NOI18N
        jPanel1.add(jLabel1);
        jLabel1.setBounds(170, 120, 60, 50);

        jPanel1.setBounds(0, 0, 690, 360);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-689)/2, (screenSize.height-357)/2, 689, 357);
    }// </editor-fold>//GEN-END:initComponents

    private void buton_adicionarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_adicionarMouseClicked
CursoMet cursomet=new CursoMet();
        if(cursomet.Buscar_Se_Ha_Curso()){
             if(i==0){  
         java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Grades().setVisible(true);
            }
        });
        dispose();
        i=1;
      }
}else{
    JOptionPane.showMessageDialog(null, "Dados incompletos para geração");
}
    }//GEN-LAST:event_buton_adicionarMouseClicked

    private void buton_deletarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_deletarMouseClicked
   CursoMet cursomet=new CursoMet();
   if(VerificaDisponibilidadedosProf()){
        if(cursomet.Buscar_Se_Ha_Curso()){
            
            if(i==0){ 
             java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new SimNao().setVisible(true);
            }
        });
    
       dispose();
        i=1;
      }
}else{
    JOptionPane.showMessageDialog(null, "Dados incompletos para geração");
}
   }
       
    }//GEN-LAST:event_buton_deletarMouseClicked

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
          
 
 
 
    }//GEN-LAST:event_formWindowClosed

    private void buton_adicionar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_adicionar1MouseClicked
 if(i==0){  
        try {
            tela.Minimiza(0);
        } catch (SQLException ex) {
            Logger.getLogger(EscolherRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }
 dispose();
  java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ChamaLayout().setVisible(true);
            }
        });       
  i=1;
      }
    }//GEN-LAST:event_buton_adicionar1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EscolherRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EscolherRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EscolherRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EscolherRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new EscolherRelatorio().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel buton_adicionar;
    private javax.swing.JLabel buton_adicionar1;
    private javax.swing.JLabel buton_deletar;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel jl_serie;
    // End of variables declaration//GEN-END:variables

    private boolean VerificaDisponibilidadedosProf() {
        ProfessorMet profmet=new ProfessorMet();
        if(profmet.VerificaPendencia()){
            return true;
        }else{
            return false;
        }
    }
}
